package LuoGu.模拟与高精度.铺地毯;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int n = (int) st.nval;
        int [][] temp = new int [n][4];
        for(int i=0;i<n;i++){
            st.nextToken();
            temp[i][0] = (int) st.nval;
            st.nextToken();
            temp[i][1] = (int) st.nval;
            st.nextToken();
            temp[i][2] = (int) st.nval;
            st.nextToken();
            temp[i][3] = (int) st.nval;
        }
        st.nextToken();
        int xx = (int) st.nval;
        st.nextToken();
        int yy = (int) st.nval;
        boolean cc = true;
        for(int i=n-1;i>=0;i--){
            int ox = temp[i][0];
            int oy = temp[i][1];
            int xl = temp[i][2];
            int yl = temp[i][3];
            if((xx>=ox&&xx<=ox+xl)&&(yy>=oy&&yy<=oy+yl)){
                System.out.print(i+1);
                cc = false;
                break;
            }
        }
        if(cc) System.out.print(-1);
    }
}
